package com.clw.utils;

import java.io.File;

/**
 * Created by chengliwei on 2018/12/16.
 */
public class PathUtil {

    private enum Delimiter {
        FILE_SEPARATOR(File.separator);

        String str;

        Delimiter(String str) {
            this.str = str;
        }

        public String getStr() {
            return str;
        }
    }

    public static boolean isJar(String path) {
        return path.endsWith(".jar") || path.endsWith(".zip");
    }

    public static String join(Delimiter delimiter, String... args) {
        StringBuilder stringBuilder = new StringBuilder();
        int i = 0;
        for (String arg : args) {
            stringBuilder.append(arg);
            if (i != args.length - 1) {
                stringBuilder.append(delimiter.getStr());
            }
            i++;
        }
        return stringBuilder.toString();
    }

    public static String join(String... args) {
        return join(Delimiter.FILE_SEPARATOR, args);
    }
}
